package ecitys.gcs

import ecitys.types.Money;

class CalculoVerbaValorBase {
	Verba verba
	
	@Override
	static Money doCalculo(){
		Money.newMoneyFromReal(getValorBaseFromVerba())
	}
	
	Money getValorBaseFromVerba(){
		def Money result
		
		if (verba.fatorDeMultiplicacao > 0)
		    result = verba.valorBase * verba.fatorDeMultiplicacao
			
		if (verba.fatorDeDivisao > 0)
		   result = result / verba.fatorDeDivisao
		
		if (verba.percentual > 0)
		   result = result * (percentual/100)
		    
		return result    	
	}
	
	static transients = ['verba','valorBaseFromVerba']
	
    static constraints = {
    }
	
	static mapping = {
		table schema:"gcs"
	}

}
